import { defineStore } from 'pinia'
import { ref } from 'vue'
export const useCounterStore = defineStore('counter', () => {
  const data=ref([])
    const id=ref(0)
  
  function add(shuju,goodsid){
    const username=localStorage.getItem('username')
    const userdata=data.value.filter(item=>item.username==username)
    const pduserdata=userdata.find(item=>item.params.goods_id==goodsid)
    if(pduserdata){
      userdata.number++
    }
    else{
      data.value.push({
        number:number,
        id:id.value++,
        username:username,
        shju:shuju,
        checked:false,
      })
    }
  }

  return {add,data }
},
 {
    persist: true,
  },
)